package com.shopoo.oauth.infrastructure.assembler;

import java.util.ArrayList;
import java.util.List;

import com.shopoo.oauth.domain.entity.Menu;
import com.shopoo.oauth.domain.entity.Role;
import com.shopoo.oauth.domain.entity.User;
import com.shopoo.oauth.infrastructure.converter.InfrastructureConverter;
import com.shopoo.oauth.infrastructure.database.dataobject.OauthMenu;
import com.shopoo.oauth.infrastructure.database.dataobject.OauthRole;
import com.shopoo.oauth.infrastructure.database.dataobject.OauthUserRoleR;

/**
 *
 * @Author <a href="mailto:android_li@sina.cn">MaoYuan.Li</a>
 * @Date 2022/3/17 1:29 AM
 */
public class InfrastructureAssembler {

	public static List<Menu> transferMenuList(List<OauthMenu> list) {
		List<Menu> targetList = new ArrayList<>();
		list.forEach(oauthMenu -> {
			Menu menu = InfrastructureConverter.INSTANCE.toMenu(oauthMenu);
			targetList.add(menu);
		});
		return targetList;
	}

	public static List<User> transferUserRoleList(List<OauthUserRoleR> list) {
		List<User> targetList = new ArrayList<>();
		list.forEach(oauthUserRoleR -> {
			User user = InfrastructureConverter.INSTANCE.toUser(oauthUserRoleR);
			targetList.add(user);
		});
		return targetList;
	}

	public static List<Role> converterRoleList(List<OauthRole> oauthRoles) {
		List<Role> list = new ArrayList<>();
		oauthRoles.forEach(oauthRole -> {
			Role role = InfrastructureConverter.INSTANCE.toRole(oauthRole);
			list.add(role);
		});
		return list;
	}
}
